
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>creoleparser.core &amp;mdash; creoleparser v0.7.3 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '../',
          VERSION:     '0.7.3',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: '.html'
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="top" title="creoleparser v0.7.3 documentation" href="../index.html" />
    <link rel="up" title="Generated API documentation" href="../modules.html" />
    <link rel="prev" title="creoleparser.dialects" href="dialects.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             accesskey="">modules</a> |</li>
        <li class="right" >
          <a href="dialects.html" title="creoleparser.dialects"
             accesskey="P">previous</a> |</li>
        <li><a href="../contents.html">creoleparser v0.7.3 documentation</a> &raquo;</li>
          <li><a href="../modules.html" accesskey="U">Generated API documentation</a> &raquo;</li> 
      </ul>
    </div>  
    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-creoleparser.core">
<span id="creoleparser-core"></span><h1><a class="reference internal" href="#module-creoleparser.core" title="creoleparser.core"><tt class="xref py py-mod docutils literal"><span class="pre">creoleparser.core</span></tt></a><a class="headerlink" href="#module-creoleparser.core" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="creoleparser.core.Parser">
<em class="property">class </em><tt class="descclassname">creoleparser.core.</tt><tt class="descname">Parser</tt><big>(</big><em>dialect</em>, <em>method='xhtml'</em>, <em>strip_whitespace=False</em>, <em>encoding='utf-8'</em><big>)</big><a class="headerlink" href="#creoleparser.core.Parser" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="creoleparser.core.Parser.__init__">
<tt class="descname">__init__</tt><big>(</big><em>dialect</em>, <em>method='xhtml'</em>, <em>strip_whitespace=False</em>, <em>encoding='utf-8'</em><big>)</big><a class="headerlink" href="#creoleparser.core.Parser.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Constructor for Parser objects</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><dl class="first last docutils">
<dt>dialect</dt>
<dd><p class="first last">Usually created using <a class="reference internal" href="dialects.html#creoleparser.dialects.create_dialect" title="creoleparser.dialects.create_dialect"><tt class="xref py py-func docutils literal"><span class="pre">creoleparser.dialects.create_dialect()</span></tt></a></p>
</dd>
<dt>method</dt>
<dd><p class="first last">This value is passed to Genshies Steam.render(). Possible values
include <tt class="docutils literal"><span class="pre">xhtml</span></tt>, <tt class="docutils literal"><span class="pre">html</span></tt>, <tt class="docutils literal"><span class="pre">xml</span></tt>, and <tt class="docutils literal"><span class="pre">text</span></tt>.</p>
</dd>
<dt>strip_whitespace</dt>
<dd><p class="first last">This value is passed to Genshies Steam.render().</p>
</dd>
<dt>encoding</dt>
<dd><p class="first last">This value is passed to Genshies Steam.render(). If <tt class="xref docutils literal"><span class="pre">None</span></tt>, the ouput
will be a unicode object.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="creoleparser.core.Parser.parse">
<tt class="descname">parse</tt><big>(</big><em>text</em>, <em>element_store=None</em>, <em>context='block'</em>, <em>environ=None</em>, <em>preprocess=True</em><big>)</big><a class="headerlink" href="#creoleparser.core.Parser.parse" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a Genshi Fragment (basically a list of Elements and text nodes).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><dl class="first last docutils">
<dt>text</dt>
<dd><p class="first last">The text to be parsed.</p>
</dd>
<dt>context</dt>
<dd><p class="first last">This is useful for marco development where (for example) supression
of paragraph tags is desired. Can be &#8216;inline&#8217;, &#8216;block&#8217;, or a list
of WikiElement objects (use with caution).</p>
</dd>
<dt>element_store</dt>
<dd><p class="first last">Internal dictionary that&#8217;s passed around a lot ;)</p>
</dd>
<dt>environ</dt>
<dd><p class="first last">This can be any type of object. It will be passed to <tt class="docutils literal"><span class="pre">macro_func</span></tt>
unchanged (for a description of <tt class="docutils literal"><span class="pre">macro_func</span></tt>, see
<a class="reference internal" href="dialects.html#creoleparser.dialects.create_dialect" title="creoleparser.dialects.create_dialect"><tt class="xref py py-func docutils literal"><span class="pre">create_dialect()</span></tt></a>).</p>
</dd>
<dt>preprocess</dt>
<dd><p class="first last">Passes text through preprocess method that replaces Windows style
line breaks.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="creoleparser.core.Parser.generate">
<tt class="descname">generate</tt><big>(</big><em>text</em>, <em>element_store=None</em>, <em>context='block'</em>, <em>environ=None</em>, <em>preprocess=True</em><big>)</big><a class="headerlink" href="#creoleparser.core.Parser.generate" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a Genshi Stream. See
<a class="reference internal" href="#creoleparser.core.Parser.parse" title="creoleparser.core.Parser.parse"><tt class="xref py py-meth docutils literal"><span class="pre">parse()</span></tt></a> for named parameter descriptions.</p>
</dd></dl>

<dl class="method">
<dt id="creoleparser.core.Parser.render">
<tt class="descname">render</tt><big>(</big><em>text</em>, <em>element_store=None</em>, <em>context='block'</em>, <em>environ=None</em>, <em>preprocess=True</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#creoleparser.core.Parser.render" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the final output string (e.g., xhtml). See
<a class="reference internal" href="#creoleparser.core.Parser.parse" title="creoleparser.core.Parser.parse"><tt class="xref py py-meth docutils literal"><span class="pre">parse()</span></tt></a> for named parameter descriptions.</p>
<p>Left over keyword arguments (<tt class="docutils literal"><span class="pre">kwargs</span></tt>) will be passed to Genshi&#8217;s Stream.render() method,
overriding the corresponding attributes of the Parser object. For more infomation on Streams,
see the <a class="reference external" href="http://genshi.edgewall.org/wiki/Documentation/streams.html#serialization-options">Genshi documentation</a>.</p>
</dd></dl>

<dl class="method">
<dt id="creoleparser.core.Parser.__call__">
<tt class="descname">__call__</tt><big>(</big><em>text</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#creoleparser.core.Parser.__call__" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper for the render method. Returns final output string.</p>
</dd></dl>

<dl class="method">
<dt id="creoleparser.core.Parser.preprocess">
<tt class="descname">preprocess</tt><big>(</big><em>text</em><big>)</big><a class="headerlink" href="#creoleparser.core.Parser.preprocess" title="Permalink to this definition">¶</a></dt>
<dd><p>This should generally be called before fragmentize().</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>text</strong> &#8211; text to be processsed.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="creoleparser.core.ArgParser">
<em class="property">class </em><tt class="descclassname">creoleparser.core.</tt><tt class="descname">ArgParser</tt><big>(</big><em>dialect</em>, <em>convert_implicit_lists=True</em>, <em>key_func=None</em>, <em>illegal_keys=()</em>, <em>convert_unicode_keys=True</em><big>)</big><a class="headerlink" href="#creoleparser.core.ArgParser" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a callable object for parsing macro argument strings</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">dialects</span> <span class="kn">import</span> <span class="n">creepy20_base</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span> <span class="o">=</span> <span class="n">ArgParser</span><span class="p">(</span><span class="n">dialect</span><span class="o">=</span><span class="n">creepy20_base</span><span class="p">())</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&quot; one two foo=&#39;three&#39; boo=&#39;four&#39; &quot;</span><span class="p">)</span>
<span class="go">([&#39;one&#39;, &#39;two&#39;], {&#39;foo&#39;: &#39;three&#39;, &#39;boo&#39;: &#39;four&#39;})</span>
</pre></div>
</div>
<p>A parser returns a two-tuple, the first item being a list of positional
arguments and the second a dictionary of keyword arguments. Argument
values are either strings or lists.</p>
<dl class="method">
<dt id="creoleparser.core.ArgParser.__init__">
<tt class="descname">__init__</tt><big>(</big><em>dialect</em>, <em>convert_implicit_lists=True</em>, <em>key_func=None</em>, <em>illegal_keys=()</em>, <em>convert_unicode_keys=True</em><big>)</big><a class="headerlink" href="#creoleparser.core.ArgParser.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Constructor for ArgParser objects</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><dl class="first last docutils">
<dt>convert_unicode_keys</dt>
<dd><p class="first last">If <em>True</em>, keys will be converted using <tt class="docutils literal"><span class="pre">str(key)</span></tt> before being
added to the output dictionary. This allows the dictionary to be
safely passed to functions using the special <tt class="docutils literal"><span class="pre">**</span></tt> form (i.e.,
<tt class="docutils literal"><span class="pre">func(**kwargs)</span></tt>).</p>
</dd>
<dt>dialect</dt>
<dd><p class="first last">Usually created using <a class="reference internal" href="dialects.html#creoleparser.dialects.creepy10_base" title="creoleparser.dialects.creepy10_base"><tt class="xref py py-func docutils literal"><span class="pre">creepy10_base()</span></tt></a>
or <a class="reference internal" href="dialects.html#creoleparser.dialects.creepy20_base" title="creoleparser.dialects.creepy20_base"><tt class="xref py py-func docutils literal"><span class="pre">creepy20_base()</span></tt></a></p>
</dd>
<dt>convert_implicit_lists</dt>
<dd><p class="first last">If <em>True</em>, all implicit lists will be converted to strings
using <tt class="docutils literal"><span class="pre">'</span> <span class="pre">'.join(list)</span></tt>. &#8220;Implicit&#8221; lists are created when
positional arguments follow keyword arguments
(see <a class="reference internal" href="dialects.html#creoleparser.dialects.creepy10_base" title="creoleparser.dialects.creepy10_base"><tt class="xref py py-func docutils literal"><span class="pre">creepy10_base()</span></tt></a>).</p>
</dd>
<dt>illegal_keys</dt>
<dd><p class="first last">A tuple of keys that will be post-fixed with an underscore if found
during parsing.</p>
</dd>
<dt>key_func</dt>
<dd><p class="first">If supplied, this function will be used to transform the names of
keyword arguments. It must accept a single positional argument.
For example, this can be used to make keywords case insensitive:</p>
<div class="last highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">string</span> <span class="kn">import</span> <span class="n">lower</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">dialects</span> <span class="kn">import</span> <span class="n">creepy20_base</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span> <span class="o">=</span> <span class="n">ArgParser</span><span class="p">(</span><span class="n">dialect</span><span class="o">=</span><span class="n">creepy20_base</span><span class="p">(),</span><span class="n">key_func</span><span class="o">=</span><span class="n">lower</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&quot; Foo=&#39;one&#39; &quot;</span><span class="p">)</span>
<span class="go">([], {&#39;foo&#39;: &#39;one&#39;})</span>
</pre></div>
</div>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="creoleparser.core.ArgParser.__call__">
<tt class="descname">__call__</tt><big>(</big><em>arg_string</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#creoleparser.core.ArgParser.__call__" title="Permalink to this definition">¶</a></dt>
<dd><p>Parses the <tt class="docutils literal"><span class="pre">arg_string</span></tt> returning a two-tuple</p>
<p>Keyword arguments (<tt class="docutils literal"><span class="pre">kwargs</span></tt>) can be used to override the corresponding
attributes of the ArgParser object (see above). However, the
<tt class="docutils literal"><span class="pre">dialect</span></tt> attribute <strong>cannot</strong> be overridden.</p>
</dd></dl>

</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h4>Previous topic</h4>
            <p class="topless"><a href="dialects.html" title="previous chapter"><tt class="docutils literal docutils literal"><span class="pre">creoleparser.dialects</span></tt></a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/modules/core.txt">Show Source</a></li>
            </ul>
          <h3>Quick search</h3>
            <form class="search" action="../search.html" method="get">
              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
          <!-- Google Sidewiki Element -->
<h3 style="background: url(//www.google.com/sidewiki/static/sidebar_element/img/sidewiki-bubble.png) no-repeat 0 0; padding: .4em 1em .5em 35px; cursor: pointer;" id="sidewiki-open-ui-button">Comments</h3>
<script src="http://www.google.com/sidewiki/static/sidebar_element/sidebar-element-compiled.js"></script>
<script defer="defer">var sidebarElement = new google.elements.sidewiki.SidebarElement(window.location.href,false);sidebarElement.bindToElement("sidewiki-open-ui-button");</script>

        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             accesskey="">modules</a> |</li>
        <li class="right" >
          <a href="dialects.html" title="creoleparser.dialects"
             accesskey="P">previous</a> |</li>
        <li><a href="../contents.html">creoleparser v0.7.3 documentation</a> &raquo;</li>
          <li><a href="../modules.html" accesskey="U">Generated API documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright Stephen Day.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.4.
    </div>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-2934490-7");
pageTracker._trackPageview();
} catch(err) {}</script>

  </body>
</html>